Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
graphology
Advanced tools
Graphology is a robust and versatile JavaScript library for creating, manipulating, and analyzing graphs. It provides a comprehensive set of tools for working with both directed and undirected graphs, and supports various graph algorithms and data structures.
Graph Creation
This feature allows you to create a new graph, add nodes, and add edges between nodes. The code sample demonstrates creating a graph, adding two nodes ('John' and 'Jane'), and adding an edge between them.
const Graph = require('graphology');
const graph = new Graph();
graph.addNode('John');
graph.addNode('Jane');
graph.addEdge('John', 'Jane');
console.log(graph.nodes()); // ['John', 'Jane']
console.log(graph.edges()); // [{ source: 'John', target: 'Jane' }]
Graph Algorithms
Graphology supports various graph algorithms, such as Dijkstra's shortest path algorithm. The code sample demonstrates creating a graph with weighted edges and finding the shortest path from node 'A' to node 'C'.
const Graph = require('graphology');
const { dijkstra } = require('graphology-shortest-path');
const graph = new Graph();
graph.addNode('A');
graph.addNode('B');
graph.addNode('C');
graph.addEdge('A', 'B', { weight: 1 });
graph.addEdge('B', 'C', { weight: 2 });
graph.addEdge('A', 'C', { weight: 4 });
const path = dijkstra(graph, 'A', 'C');
console.log(path); // ['A', 'B', 'C']
Graph Analysis
Graphology provides tools for analyzing graphs, such as calculating centrality metrics. The code sample demonstrates creating a graph and calculating the degree centrality of each node.
const Graph = require('graphology');
const { degreeCentrality } = require('graphology-metrics/centrality');
const graph = new Graph();
graph.addNode('A');
graph.addNode('B');
graph.addNode('C');
graph.addEdge('A', 'B');
graph.addEdge('B', 'C');
graph.addEdge('A', 'C');
const centrality = degreeCentrality(graph);
console.log(centrality); // { A: 2, B: 2, C: 2 }
Cytoscape.js is a graph theory library for visualization and analysis. It is highly optimized for large graphs and provides a rich set of features for graph manipulation and visualization. Compared to Graphology, Cytoscape.js is more focused on visualization and interactive graph exploration.
vis-network is a dynamic, browser-based visualization library for network graphs. It allows for interactive exploration and manipulation of graphs. While Graphology focuses on graph data structures and algorithms, vis-network emphasizes visualization and user interaction.
Sigma is a JavaScript library dedicated to graph drawing. It provides a simple way to visualize graphs and supports various layout algorithms. Sigma is more focused on rendering and visualizing graphs, whereas Graphology provides a more comprehensive set of tools for graph manipulation and analysis.
graphology
is a specification for a robust & multipurpose JavaScript Graph
object and aiming at supporting various kinds of graphs under a same unified interface.
You will also find here the source for the reference implementation of this specification.
npm install graphology
Full documentation for the library/specs is available here.
Contributions are obviously welcome. Just be sure to lint & add/run relevant unit tests.
# Installing locally
git clone git@github.com:graphology/graphology.git
cd graphology
npm install
# Linting
npm run lint
# Running the unit tests
npm test
# Building & Distribution
npm run build
npm run dist
0.7.1
FAQs
A robust and multipurpose Graph object for JavaScript.
The npm package graphology receives a total of 247,014 weekly downloads. As such, graphology popularity was classified as popular.
We found that graphology demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.